﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using System.Xml;
using System.IO;
using MDM.GUI.MDM.Business;
using MDM.GUI.MDM.DataObjects;
using DevExpress.Skins;
using System.Threading;
using System.Drawing.Imaging;


namespace MDM.GUI
{
    public partial class MainForm : DevExpress.XtraEditors.XtraForm
    {
        int i = 5;
        public MainForm()
        {
            InitializeComponent();

        }


        ImageList itemImageList = new ImageList();
        private void MainForm_Load(object sender, EventArgs e)
        {
            itemImageList.ImageSize = picIconModule.Size;
            MDM.DataObjects.Installed itemModule = AQFramework.Utilities.Serializer<MDM.DataObjects.Installed>.Load(Common.sModuleDestinationPath + "\\installed.xml");
            foreach (MDM.DataObjects.Module itemMod in itemModule.Modules)
            {

                System.Drawing.Image image = Image.FromFile(Common.sModuleDestinationPath+"\\"+ itemMod.Images);
                itemImageList.Images.Add(itemMod.Name,image);
    
            }
            ImageList itemSmallList = new ImageList();
            itemSmallList.ImageSize = new Size(17, 17);
            foreach (Image item in itemImageList.Images)
            {
                itemSmallList.Images.Add(item);
            }
   
            listView1.LargeImageList = itemImageList;
            listView1.SmallImageList = itemSmallList;



            //luu lai giao dien
            StreamReader streamReader = new StreamReader("SkinAction.txt");
            string text = streamReader.ReadToEnd();
            streamReader.Close();
            defaultLookAndFeel1.LookAndFeel.SkinName = text;
            //luu lai giao dien END

            UserController.LoadUser();
            LoginForm login = new LoginForm();
            login.ShowDialog();
            //this.Text = Application.StartupPath;
            ModuleManager.LoadModuleList();

            //load file

            ModuleInfors ds = ConvertModuleInforsToDataset();

            //show list view

         //B   MDM.DataObjects.Installed itemModule = AQFramework.Utilities.Serializer<MDM.DataObjects.Installed>.Load(Common.sModuleDestinationPath + "\\installed.xml");

            foreach (MDM.DataObjects.Module itemMod in itemModule.Modules)
            {
                ListViewItem listviewitem = new ListViewItem(itemMod.Name);
                //listviewitem.SubItems.Add(item.Author);
                listviewitem.SubItems.Add(itemMod.DateInstall);
                listviewitem.SubItems.Add(itemMod.Size);
                listviewitem.SubItems.Add(itemMod.Version);

                if (itemMod.Name == null)
                {

                    itemImageList.Images.Clear();
                    listView1.Items.Clear();
                    listviewitem.ImageIndex = itemImageList.Images.IndexOfKey(null);
                }
                else
                {
                    listviewitem.ImageIndex = itemImageList.Images.IndexOfKey(itemMod.Name);
                }

            //    listviewitem.ImageKey = itemMod.Name;
            //    listviewitem.ImageIndex = itemImageList.Images.IndexOfKey(itemMod.Name);
                listView1.Items.Add(listviewitem);


                //listviewitem.
            }
            //end show list view


            /*

            grpViewModdule.DataSource = ds;
            grpViewModdule.DataMember = "Module";

            this.gridView1.RowClick += new DevExpress.XtraGrid.Views.Grid.RowClickEventHandler(gridView1_RowClick);
            this.gridView1.RowCellClick += new DevExpress.XtraGrid.Views.Grid.RowCellClickEventHandler(gridView1_RowClick);
            this.gridView1.MouseUp += new MouseEventHandler(gridView1_MouseUp);
            */

        }

        private void UpdateListView()
        {
            picIconModule.Image=null;
            itemImageList.Images.Clear();
            listView1.Items.Clear();
            MDM.DataObjects.Installed itemModule = AQFramework.Utilities.Serializer<MDM.DataObjects.Installed>.Load(Common.sModuleDestinationPath + "\\installed.xml");

            foreach (MDM.DataObjects.Module itemMod in itemModule.Modules)
            {
                System.Drawing.Image image = Image.FromFile(Common.sModuleDestinationPath + "\\" + itemMod.Images);
                itemImageList.Images.Add(itemMod.Name, image);
                //  listView1.LargeImageList = i;
                listView1.LargeImageList = itemImageList;
                //listviewitem


                ListViewItem listviewitem = new ListViewItem(itemMod.Name);
                //listviewitem.SubItems.Add(item.Author);
                listviewitem.SubItems.Add(itemMod.DateInstall);
                listviewitem.SubItems.Add(itemMod.Size);
                listviewitem.SubItems.Add(itemMod.Version);
                if (itemMod.Name == null)
                {
                    itemImageList.Images.Clear();
                    listView1.Items.Clear();
                    listviewitem.ImageIndex = itemImageList.Images.IndexOfKey(null);
                }
                else 
                {
              
                    listviewitem.ImageIndex = itemImageList.Images.IndexOfKey(itemMod.Name);
                }
                
            //    listviewitem.ImageIndex = itemImageList.Images.IndexOfKey(itemMod.Name);
                listView1.Items.Add(listviewitem);


            }

            ImageList itemSmallList = new ImageList();
            itemSmallList.ImageSize = new Size(17, 17);
            foreach (Image item in itemImageList.Images)
            {
                itemSmallList.Images.Add(item);
            }

  
            listView1.SmallImageList = itemSmallList;
        }

        private ModuleInfors ConvertModuleInforsToDataset()
        {
            ModuleInfors dsModuleInfors = new ModuleInfors();
            // use the foreach to create new row from each object of Common.aModuleInfor. Add row to tables
            //dsModuleInfors.Tables["Module"].Rows.Add
            //   DataRow drTmp;
            foreach (ModuleInfor itemModules in Common.aModInfor)
            {
                dsModuleInfors.Tables["Module"].Rows.Add(itemModules.Name,
                    //itemModules.Author,
                                                         itemModules.DateInstall,
                                                         itemModules.Size,
                                                         itemModules.Version);

            }
            // dsModuleInfors.Tables.Add(

            // insert data here
            // dsModuleInfors.Tables.Add(tbModule);
            return dsModuleInfors;
        }



       


        private void btnUpgrade_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog moduleFolder = new FolderBrowserDialog();
            //
            //if( moduleFolder.
            //
            DialogResult result = moduleFolder.ShowDialog();
            //
            if (result == DialogResult.Cancel)
            {
                return;
            }
            //
            Common.sModulePath = moduleFolder.SelectedPath;
            DirectoryInfo dirModPath = new DirectoryInfo(Common.sModulePath);
            Common.sModuleName = dirModPath.Name;
            MDM.DataObjects.Version itemVersion = AQFramework.Utilities.Serializer<MDM.DataObjects.Version>.Load(Common.sModulePath + "\\" + Common.sVersionXmlName);
            MDM.DataObjects.Installed itemModuleList = AQFramework.Utilities.Serializer<MDM.DataObjects.Installed>.Load(Common.sModuleDestinationPath + "\\installed.xml");
            
            MDM.Business.ModuleManager.UpdateInstalledModule(listView1.SelectedItems[0].SubItems[0].Text);

            UpdateForm a = new UpdateForm(i);
            a.ShowDialog();


            UpdateListView();
            //Update
        }






        private void btnInstall_Click(object sender, EventArgs e)
        {



            FolderBrowserDialog moduleFolder = new FolderBrowserDialog();
            //
            //if( moduleFolder.
            //
            DialogResult result = moduleFolder.ShowDialog();
            //
            if (result == DialogResult.Cancel)
            {
                return;
            }
            //
            Common.sModulePath = moduleFolder.SelectedPath;
            DirectoryInfo dirModPath = new DirectoryInfo(Common.sModulePath);
            Common.sModuleName = dirModPath.Name;

            MDM.DataObjects.Version itemVersion = AQFramework.Utilities.Serializer<MDM.DataObjects.Version>.Load(Common.sModulePath + "\\" + Common.sVersionXmlName);
            MDM.DataObjects.Installed itemModuleList = AQFramework.Utilities.Serializer<MDM.DataObjects.Installed>.Load(Common.sModuleDestinationPath + "\\installed.xml");


            //////// Code lấy Name của Module mới được chọn để Install.

            string sGetName = "";
            foreach (MDM.DataObjects.File itemVer in itemVersion.Installs.Files)
            {

                bool bltest = itemVer.Name.EndsWith("exe");
                if (bltest == true)
                {
                    for (int i = itemVer.Name.Length - 1; i >= 0; i = i - 1)
                    {

                        if (itemVer.Name[i] == '.')
                        {
                            sGetName = itemVer.Name.Substring(0, i);

                            break;
                        }

                    }

                    break;
                }
            }


            ///// Đoạn code để so sánh và chọn có Install new module hay không ?

            foreach (MDM.DataObjects.Module itemMod in itemModuleList.Modules)
            {

                if (itemMod.Name == sGetName)
                {

                    if (itemMod.Version.CompareTo(itemVersion.version) >= 0)
                    //Greater than zero 	This instance is greater than value. 
                    {
                        MessageBox.Show("Module bạn muốn cài đặt hiện đã có trong hệ thống và là phiên bản mới nhất.");
                        return;
                    }

                    if (itemMod.Version.CompareTo(itemVersion.version) < 0)
                    //   Less than zeoro .	This instance is less than value.
                    {
                        MessageBox.Show("Module bạn muốn cài đặt hiện đã có trong hệ thống, bạn có muốn cài đặt lên version mới nhất hiện tại không ? đây là box có lựa chon yes no");

                        UpdateForm itemUpdateForm = new UpdateForm(itemVersion.Installs.Files.Count);
                        itemUpdateForm.Show(this);
                      
                        doUpdate(sGetName);


                     /*   //tao thread, de chay da luong rieng
                        Thread itemThread1 = new Thread(new ParameterizedThreadStart(doUpdate));
                        itemThread1.Start(sGetName);
                        */

                        return;
                    }

                }

            }

      

            //gan so file vao
            InstallForm a = new InstallForm(itemVersion.Installs.Files.Count);
            a.Show(this);

            doInstall();
        
          /*  //tao thread, de chay da luong rieng
            Thread itemThread = new Thread(new ThreadStart(doInstall));
            itemThread.Start();
            */

        }
        public void doInstall()
        {
            MDM.Business.ModuleManager.InstallNewModule();


            this.Show();


            UpdateListView();
            
        }


       public void doUpdate(object sModuleName)
        {
            MDM.Business.ModuleManager.UpdateInstalledModule((string)sModuleName);


            this.Show();


            UpdateListView();

        }


       public void doUninstall(object sModuleName)
       {
           MDM.Business.ModuleManager.UnInstallModule((string)sModuleName);


           this.Show();


           UpdateListView();

       }

        
          



        private void btnUninstall_Click(object sender, EventArgs e)
        {
            MDM.DataObjects.Installed itemModule = AQFramework.Utilities.Serializer<MDM.DataObjects.Installed>.Load(Common.sModuleDestinationPath + "\\installed.xml");
            foreach (MDM.DataObjects.Module itemMod in itemModule.Modules)
            {


                MDM.DataObjects.Version itemVersion = AQFramework.Utilities.Serializer<MDM.DataObjects.Version>.Load(Common.sModuleDestinationPath + "\\" + itemMod.VersionID + ".xml");
                foreach (MDM.DataObjects.File item in itemVersion.Installs.Files)
                {
                    UninstallForm itemUninstallForm = new UninstallForm(itemVersion.Installs.Files.Count);
                    itemUninstallForm.ShowDialog();
                    doUninstall(listView1.SelectedItems[0].SubItems[0].Text);


                }
            }

        }
















        private void btnView_Click(object sender, EventArgs e)
        {

        }
















        private void btnHistoryData_Click(object sender, EventArgs e)
        {
            XtraForm4 a = new XtraForm4();
            a.ShowDialog();
        }














        private void btnQuestion_Click(object sender, EventArgs e)
        {
            XtraForm7 a = new XtraForm7();
            a.ShowDialog();
        }











        private void panel1_Paint(object sender, PaintEventArgs e)
        {

        }


        //hien mau theo Dex
        /*  private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
          {
              DevExpress.LookAndFeel.UserLookAndFeel.Default.SetSkinStyle(comboBox1.SelectedItem.ToString());
          }*/
        //lam phan show phong nen
        /*
        private void dropDownButton1_Click(object sender, EventArgs e)
        {
            DevExpress.LookAndFeel.UserLookAndFeel.Default.SetSkinStyle("Money Twins");
             foreach (SkinContainer cnt in SkinManager.Default.Skins)
             {
                 dropDownButton1.;
             }
            //dropDownButton1.
           
        }
        */

        private void listView1_SelectedIndexChanged(object sender, EventArgs e)
        {
        }

        private void listView1_MouseClick(object sender, MouseEventArgs e)
        {
            listView2.Items.Clear();
            btnUninstall.Enabled = true;
            string a = "Tên Module: " + listView1.SelectedItems[0].SubItems[0].Text;
            string c = "Ngày: " + listView1.SelectedItems[0].SubItems[1].Text;
            string d = "Độ lớn: " + listView1.SelectedItems[0].SubItems[2].Text;
            string stre = "Phiên bản" + listView1.SelectedItems[0].SubItems[3].Text;

            listView2.Items.Add(a);
            listView2.Items.Add(c);
            listView2.Items.Add(d);
            listView2.Items.Add(stre);
            int index = listView1.SelectedItems[0].ImageIndex;
            if (index>=0)
            {
                picIconModule.Image = itemImageList.Images[listView1.SelectedItems[0].SubItems[0].Text]; 
            }
      
        }

        private void toolStripMenuItem2_Click(object sender, EventArgs e)
        {
            MDM.DataObjects.Installed itemModule = AQFramework.Utilities.Serializer<MDM.DataObjects.Installed>.Load(Common.sModuleDestinationPath + "\\installed.xml");
            foreach (MDM.DataObjects.Module itemMod in itemModule.Modules)
            {

                MDM.DataObjects.Version itemVersion = AQFramework.Utilities.Serializer<MDM.DataObjects.Version>.Load(Common.sModuleDestinationPath + "\\" + itemMod.VersionID + ".xml");
                foreach (MDM.DataObjects.File item in itemVersion.Installs.Files)
                {
                    doUninstall(listView1.SelectedItems[0].SubItems[0].Text);
                    UninstallForm itemUninstallForm = new UninstallForm(itemVersion.Installs.Files.Count);
                    itemUninstallForm.ShowDialog();
                    return;
                 


                }
            }
        }


        private void barButtonItem5_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            listView1.View = View.LargeIcon;
        }

        private void barButtonItem6_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            listView1.View = View.Details;
        }

        private void barButtonItem7_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            listView1.View = View.SmallIcon;
        }
        private void barButtonItem8_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            listView1.View = View.List;
        }
        private void barButtonItem9_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            listView1.View = View.Tile;
        }

        private void barButtonItem11_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            defaultLookAndFeel1.LookAndFeel.SkinName = "Caramel";
            FileInfo t = new FileInfo("SkinAction.txt");
            StreamWriter Tex = t.CreateText();
            Tex.Write("Caramel");
            Tex.Close();

        }

        private void barButtonItem12_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            defaultLookAndFeel1.LookAndFeel.SkinName = "Money Twins";
            FileInfo t = new FileInfo("SkinAction.txt");
            StreamWriter Tex = t.CreateText();
            Tex.Write("Money Twins");
            Tex.Close();

        }

        private void barButtonItem13_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            defaultLookAndFeel1.LookAndFeel.SkinName = "Lilian";
            FileInfo t = new FileInfo("SkinAction.txt");
            StreamWriter Tex = t.CreateText();
            Tex.Write("Lilian");
            Tex.Close();
        }

        private void barButtonItem14_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            defaultLookAndFeel1.LookAndFeel.SkinName = "Black";
            FileInfo t = new FileInfo("SkinAction.txt");
            StreamWriter Tex = t.CreateText();
            Tex.Write("Black");
            Tex.Close();
        }

        private void barButtonItem15_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            defaultLookAndFeel1.LookAndFeel.SkinName = "Blue";
        }

        private void barButtonItem48_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            defaultLookAndFeel1.LookAndFeel.SkinName = "Seven";
        }

        private void barButtonItem34_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            defaultLookAndFeel1.LookAndFeel.SkinName = "Valentine";
            FileInfo t = new FileInfo("SkinAction.txt");
            StreamWriter Tex = t.CreateText();
            Tex.Write("Valentine");
            Tex.Close();
        }

        private void dropDownButton1_Click(object sender, EventArgs e)
        {

        }

        private void barButtonItem53_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            defaultLookAndFeel1.LookAndFeel.SkinName = " Caramel";
            FileInfo t = new FileInfo("SkinAction.txt");
            StreamWriter Tex = t.CreateText();
            Tex.Write("Caramel");
            Tex.Close();

        }

        private void barButtonItem54_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            defaultLookAndFeel1.LookAndFeel.SkinName = " Money Twins";
            FileInfo t = new FileInfo("SkinAction.txt");
            StreamWriter Tex = t.CreateText();
            Tex.Write("Money Twins");
            Tex.Close();

        }

        private void barButtonItem55_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            defaultLookAndFeel1.LookAndFeel.SkinName = "Lilian";
            FileInfo t = new FileInfo("SkinAction.txt");
            StreamWriter Tex = t.CreateText();
            Tex.Write("Lilian");
            Tex.Close();
        }

        private void barButtonItem56_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            defaultLookAndFeel1.LookAndFeel.SkinName = "The Asphalt World";
            FileInfo t = new FileInfo("SkinAction.txt");
            StreamWriter Tex = t.CreateText();
            Tex.Write("The Asphalt World");
            Tex.Close();
        }

        private void barButtonItem57_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            defaultLookAndFeel1.LookAndFeel.SkinName = "iMaginary";
            FileInfo t = new FileInfo("SkinAction.txt");
            StreamWriter Tex = t.CreateText();
            Tex.Write("iMaginary");
            Tex.Close();
        }

        private void barButtonItem58_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            defaultLookAndFeel1.LookAndFeel.SkinName = "Black";
            FileInfo t = new FileInfo("SkinAction.txt");
            StreamWriter Tex = t.CreateText();
            Tex.Write("Black");
            Tex.Close();
        }

        private void barButtonItem59_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            defaultLookAndFeel1.LookAndFeel.SkinName = "Blue";
            FileInfo t = new FileInfo("SkinAction.txt");
            StreamWriter Tex = t.CreateText();
            Tex.Write("Blue");
            Tex.Close();
        }

        private void barButtonItem60_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            defaultLookAndFeel1.LookAndFeel.SkinName = "Office 2007 Blue";
            FileInfo t = new FileInfo("SkinAction.txt");
            StreamWriter Tex = t.CreateText();
            Tex.Write("Office 2007 Blue");
            Tex.Close();
        }

        private void barButtonItem61_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            defaultLookAndFeel1.LookAndFeel.SkinName = "Office 2007 Black";
            FileInfo t = new FileInfo("SkinAction.txt");
            StreamWriter Tex = t.CreateText();
            Tex.Write("Office 2007 Black");
            Tex.Close();
        }
        //Office 2007 Silver
        private void barButtonItem62_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            defaultLookAndFeel1.LookAndFeel.SkinName = "Office 2007 Silver";
            FileInfo t = new FileInfo("SkinAction.txt");
            StreamWriter Tex = t.CreateText();
            Tex.Write("Office 2007 Silver");
            Tex.Close();
        }

        private void barButtonItem63_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            defaultLookAndFeel1.LookAndFeel.SkinName = "Office 2007 Green";
            FileInfo t = new FileInfo("SkinAction.txt");
            StreamWriter Tex = t.CreateText();
            Tex.Write("Office 2007 Green");
            Tex.Close();
        }

        private void barButtonItem64_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            defaultLookAndFeel1.LookAndFeel.SkinName = "Office 2007 Pink";
            FileInfo t = new FileInfo("SkinAction.txt");
            StreamWriter Tex = t.CreateText();
            Tex.Write("Office 2007 Pink");
            Tex.Close();
        }

        private void barButtonItem65_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            defaultLookAndFeel1.LookAndFeel.SkinName = "Office 2010 Blue";
            FileInfo t = new FileInfo("SkinAction.txt");
            StreamWriter Tex = t.CreateText();
            Tex.Write("Office 2010 Blue");
            Tex.Close();
        }

        private void barButtonItem66_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            defaultLookAndFeel1.LookAndFeel.SkinName = "Office 2010 Black";
            FileInfo t = new FileInfo("SkinAction.txt");
            StreamWriter Tex = t.CreateText();
            Tex.Write("Office 2010 Black");
            Tex.Close();
        }

        private void barButtonItem67_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            defaultLookAndFeel1.LookAndFeel.SkinName = "Office 2010 Silver";
            FileInfo t = new FileInfo("SkinAction.txt");
            StreamWriter Tex = t.CreateText();
            Tex.Write("Office 2010 Silver");
            Tex.Close();
        }

        private void barButtonItem69_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            defaultLookAndFeel1.LookAndFeel.SkinName = "Coffee";
            FileInfo t = new FileInfo("SkinAction.txt");
            StreamWriter Tex = t.CreateText();
            Tex.Write("Coffee");
            Tex.Close();
        }
        //Liquid Sky
        private void barButtonItem72_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            defaultLookAndFeel1.LookAndFeel.SkinName = "Liquid Sky";
            FileInfo t = new FileInfo("SkinAction.txt");
            StreamWriter Tex = t.CreateText();
            Tex.Write("Liquid Sky");
            Tex.Close();
        }

        private void barButtonItem75_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            defaultLookAndFeel1.LookAndFeel.SkinName = "London Liquid Sky";
            FileInfo t = new FileInfo("SkinAction.txt");
            StreamWriter Tex = t.CreateText();
            Tex.Write("London Liquid Sky");
            Tex.Close();
        }

        private void barButtonItem76_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            defaultLookAndFeel1.LookAndFeel.SkinName = "Glass Oceans";
            FileInfo t = new FileInfo("SkinAction.txt");
            StreamWriter Tex = t.CreateText();
            Tex.Write("Glass Oceans");
            Tex.Close();
        }

        private void barButtonItem77_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            defaultLookAndFeel1.LookAndFeel.SkinName = "Stardust";
            FileInfo t = new FileInfo("SkinAction.txt");
            StreamWriter Tex = t.CreateText();
            Tex.Write("Stardust");
            Tex.Close();
        }

        private void barButtonItem78_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            defaultLookAndFeel1.LookAndFeel.SkinName = "Xmas 2008 Blue";
            FileInfo t = new FileInfo("SkinAction.txt");
            StreamWriter Tex = t.CreateText();
            Tex.Write("Xmas 2008 Blue");
            Tex.Close();
        }

        private void barButtonItem79_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            defaultLookAndFeel1.LookAndFeel.SkinName = "Valentine";
            FileInfo t = new FileInfo("SkinAction.txt");
            StreamWriter Tex = t.CreateText();
            Tex.Write("Valentine");
            Tex.Close();
        }

        private void barButtonItem80_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            defaultLookAndFeel1.LookAndFeel.SkinName = "McSkin";
            FileInfo t = new FileInfo("SkinAction.txt");
            StreamWriter Tex = t.CreateText();
            Tex.Write("McSkin");
            Tex.Close();
        }

        private void barButtonItem81_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            defaultLookAndFeel1.LookAndFeel.SkinName = "Summer 2008";
            FileInfo t = new FileInfo("SkinAction.txt");
            StreamWriter Tex = t.CreateText();
            Tex.Write("Summer 2008");
            Tex.Close();
        }

        private void barButtonItem82_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            defaultLookAndFeel1.LookAndFeel.SkinName = "Pumpkin";
            FileInfo t = new FileInfo("SkinAction.txt");
            StreamWriter Tex = t.CreateText();
            Tex.Write("Pumpkin");
            Tex.Close();
        }

        private void barButtonItem83_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            defaultLookAndFeel1.LookAndFeel.SkinName = "Dark Side";
            FileInfo t = new FileInfo("SkinAction.txt");
            StreamWriter Tex = t.CreateText();
            Tex.Write("Dark Side");
            Tex.Close();
        }

        private void barButtonItem84_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            defaultLookAndFeel1.LookAndFeel.SkinName = "Springtime";
            FileInfo t = new FileInfo("SkinAction.txt");
            StreamWriter Tex = t.CreateText();
            Tex.Write("Springtime");
            Tex.Close();
        }

        private void barButtonItem85_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            defaultLookAndFeel1.LookAndFeel.SkinName = "Darkroom";
            FileInfo t = new FileInfo("SkinAction.txt");
            StreamWriter Tex = t.CreateText();
            Tex.Write("Darkroom");
            Tex.Close();
        }

        private void barButtonItem86_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            defaultLookAndFeel1.LookAndFeel.SkinName = "Foggy";
            FileInfo t = new FileInfo("SkinAction.txt");
            StreamWriter Tex = t.CreateText();
            Tex.Write("Foggy");
            Tex.Close();
        }

        private void barButtonItem87_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            defaultLookAndFeel1.LookAndFeel.SkinName = "High Contrast";
            FileInfo t = new FileInfo("SkinAction.txt");
            StreamWriter Tex = t.CreateText();
            Tex.Write("High Contrast");
            Tex.Close();
        }

        private void barButtonItem88_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            defaultLookAndFeel1.LookAndFeel.SkinName = "Seven";
            FileInfo t = new FileInfo("SkinAction.txt");
            StreamWriter Tex = t.CreateText();
            Tex.Write("Seven");
            Tex.Close();
        }

        private void barButtonItem90_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            defaultLookAndFeel1.LookAndFeel.SkinName = "Seven Classic";
            FileInfo t = new FileInfo("SkinAction.txt");
            StreamWriter Tex = t.CreateText();
            Tex.Write("Seven Classic");
            Tex.Close();
        }

        private void barButtonItem93_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            defaultLookAndFeel1.LookAndFeel.SkinName = "Sharp";
            FileInfo t = new FileInfo("SkinAction.txt");
            StreamWriter Tex = t.CreateText();
            Tex.Write("Sharp");
            Tex.Close();
        }

        private void barButtonItem96_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            defaultLookAndFeel1.LookAndFeel.SkinName = "Sharp Plus";
            FileInfo t = new FileInfo("SkinAction.txt");
            StreamWriter Tex = t.CreateText();
            Tex.Write("Sharp Plus");
            Tex.Close();
        }

        private void barButtonItem99_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            defaultLookAndFeel1.LookAndFeel.SkinName = "DexExpress Style";
            FileInfo t = new FileInfo("SkinAction.txt");
            StreamWriter Tex = t.CreateText();
            Tex.Write("DexExpress Style");
            Tex.Close();
        }

        private void toolStripMenuItem1_Click(object sender, EventArgs e)
        {


            FolderBrowserDialog moduleFolder = new FolderBrowserDialog();
            //
            //if( moduleFolder.
            //
            DialogResult result = moduleFolder.ShowDialog();
            //
            if (result == DialogResult.Cancel)
            {
                return;
            }
            //
            Common.sModulePath = moduleFolder.SelectedPath;
            DirectoryInfo dirModPath = new DirectoryInfo(Common.sModulePath);
            Common.sModuleName = dirModPath.Name;
            MDM.DataObjects.Version itemVersion = AQFramework.Utilities.Serializer<MDM.DataObjects.Version>.Load(Common.sModulePath + "\\" + Common.sVersionXmlName);
            MDM.DataObjects.Installed itemModuleList = AQFramework.Utilities.Serializer<MDM.DataObjects.Installed>.Load(Common.sModuleDestinationPath + "\\installed.xml");

            MDM.Business.ModuleManager.UpdateInstalledModule(listView1.SelectedItems[0].SubItems[0].Text);

            UpdateForm a = new UpdateForm(i);
            a.ShowDialog();


            UpdateListView();

       /*     MDM.DataObjects.Installed itemModule = AQFramework.Utilities.Serializer<MDM.DataObjects.Installed>.Load(Common.sModuleDestinationPath + "\\installed.xml");
            foreach (MDM.DataObjects.Module itemMod in itemModule.Modules)
            {
                MDM.DataObjects.Version itemVersion = AQFramework.Utilities.Serializer<MDM.DataObjects.Version>.Load(Common.sModuleDestinationPath + "\\" + itemMod.VersionID + ".xml");
                foreach (MDM.DataObjects.File item in itemVersion.Installs.Files)
                {
                    doUpdate(listView1.SelectedItems[0].SubItems[0].Text);
                    UpdateForm itemUninstallForm = new UpdateForm(itemVersion.Installs.Files.Count);
                    itemUninstallForm.ShowDialog();
                   // doUpdate(listView1.SelectedItems[0].SubItems[0].Text);
                }
            }

          /*  MDM.Business.ModuleManager.UpdateInstalledModule(listView1.SelectedItems[0].SubItems[0].Text);
            //tao thread, de chay da luong rieng
            Thread t = new Thread(new ThreadStart(doInstall));
            t.Start();*/
        }

        private void picIconModule_EditValueChanged(object sender, EventArgs e)
        {

        }





    }
}